package com.liqw.activiti.service.impl;

import com.liqw.activiti.service.TaskService;
import lombok.extern.slf4j.Slf4j;
import org.activiti.engine.HistoryService;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.runtime.ProcessInstance;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
public class TaskServiceImpl implements TaskService {
    @Autowired
    private RuntimeService runtimeService;
    @Autowired
    private org.activiti.engine.TaskService taskService;
    @Autowired
    private HistoryService historyService;

    @Override
    public ProcessInstance start(String processDefinitionKey) {
        ProcessInstance instance = runtimeService.startProcessInstanceByKey(processDefinitionKey);
        String id = instance.getId();
        System.out.println("流程id=" + id);
        return instance;
    }

    @Override
    public boolean submit(String taskId) {
        taskService.complete(taskId);
        return true;
    }

    @Override
    public boolean reject(String taskId) {
        return true;
    }

    @Override
    public boolean cancel(String taskId) {
        return true;
    }

    @Override
    public boolean transfer(String taskId) {
        return true;
    }

    @Override
    public boolean pending(String taskId) {
        return true;
    }
}
